<%@ page language="java" pageEncoding="utf-8"%>
<%
String style=application.getInitParameter("style");
// 设置样式
application.setAttribute("style", style);
// 根据样式设置dhx皮肤
if(style.startsWith("web_")){// 目前web的样式集成进去有问题
    application.setAttribute("skin", "dhx_web");
}else{
    application.setAttribute("skin", "dhx_skyblue");// 这是大多数dhtmlx组件默认的skin
}
%>
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/dhx2/dhtmlx.css' />">
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/dhx2/${style}/dhtmlx_custom.css' />">
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/easyui/icon.css'/>">
<link rel="stylesheet" type="text/css" href="<c:url value='/styles/schedule/${style}/dhtmlxscheduler.css' />">

<link rel="stylesheet" type="text/css" href="<c:url value='/styles/easyui/default/validatebox.css'/>">

<link rel="stylesheet" type="text/css" href="<c:url value='/styles/app/${style}/wmapp.css'/>">

<script src="<c:url value='/javascript/jquery-1.4.4.min.js'/>" type="text/javascript"></script>
<script src="<c:url value='/javascript/jquery.json-2.2.js'/>" type="text/javascript"></script>

<script src="<c:url value='/javascript/dhx2/dhtmlx.js' />" type="text/javascript"></script>
<script src="<c:url value='/javascript/schedule/dhtmlxscheduler.js' />" type="text/javascript"></script>
<script src="<c:url value='/javascript/schedule/dhtmlxscheduler_serialize.js' />" type="text/javascript"></script>
<script src="<c:url value='/javascript/schedule/dhtmlxscheduler_recurring.js' />" type="text/javascript"></script>
<script src="<c:url value='/javascript/schedule/dhtmlxscheduler_active_links.js' />" type="text/javascript"></script>
<script src="<c:url value='/javascript/schedule/dhtmlxscheduler_agenda_view.js' />" type="text/javascript"></script>

<script src="<c:url value='/javascript/easyui/plugins/jquery.validatebox.js'/>" type="text/javascript"></script>
<script src="<c:url value='/javascript/easyui/plugins/jquery.form.js'/>" type="text/javascript"></script>

<script src="<c:url value='/javascript/app/xdate.js'/>" type="text/javascript"></script>

<c:if test="${sessionScope.locale=='zh_CN'}">
	<script type="text/javascript" src="<c:url value='/javascript/messages_zh_CN.js'/>"></script>
</c:if>
<c:if test="${sessionScope.locale=='zh_TW'}">
	<script type="text/javascript" src="<c:url value='/javascript/messages_zh_TW.js'/>"></script>
</c:if>
<c:if test="${sessionScope.locale=='en'||empty sessionScope.locale}">
	<script type="text/javascript" src="<c:url value='/javascript/messages_en.js'/>"></script>
</c:if>

<script type="text/javascript">
	scheduler.toJSON = function(){
		var json = [];
		var attrs = this.data_attributes();
		for (var a in this._events){
			var ev = this._events[a];
			if (ev.id.toString().indexOf("#")!=-1) continue;
			var ev = this._events[a];
			/*
			var line =[];	
			for (var i=0; i < attrs.length; i++)
				line.push(' '+attrs[i][0]+':"'+((attrs[i][1]?attrs[i][1](ev[attrs[i][0]]):ev[attrs[i][0]])||"").toString().replace(/\n/g,"")+'" ');
			json.push("{"+line.join(",")+"}");
			*/
			var line={};
			for (var i=0; i < attrs.length; i++){
				line[attrs[i][0]]=(attrs[i][1]?attrs[i][1](ev[attrs[i][0]]):ev[attrs[i][0]])||"";
			}
				
			json.push(line);
		}
		//return "["+json.join(",\n")+"]";
		return $.toJSON(json);
	};
	//ajax request wrapper for authorization
	(function($){
		$.wmapp={};
		
		$.wmapp.perm=function(ajaxfunc){
			var legal=false;
			
			$.ajax({
				url:"<c:url value='/app/perm/touch' />",
				async:false,
				data:{
					times:new Date().valueOf()
				},
				success:function(data){
					if(data=='__expired__'){
						if(parent){
							parent.location.href="<c:url value='/index.jsp' />";
						}else{
							location.href="<c:url value='/index.jsp' />";
						}
					}else{
						legal=true;
					}
				}
			});
			
			if(legal&&(typeof(ajaxfunc) == "function")){
				ajaxfunc();
			}
		}
	})(jQuery);
</script>